<template>
  <div class="cons_doctor_grid">
    <template v-if="teamHospitalList.length>0">
      <div class="cons_doctor_item" v-for="(item,index) in teamHospitalList" :key="item.id">
        <div class="cons_doctor_info">
          <div class="avatar">
            <img class="itemImg" v-if="item.img" :src="item.img">
            <img class="defaultImg" v-else src="~@/assets/images/teamhospital.png" alt>
          </div>
          <div v-if="consType=='hospital'" class="info">{{item.name}}</div>
          <div v-else class="info">{{item.teamName}}</div>
        </div>
        <div class="cons_doctor_navs">
          <el-button class="nav_btn" size="mini" type="primary" plain @click="goDetails(index)">详情</el-button>
          <el-button
            class="nav_btn"
            size="mini"
            type="primary"
            plain
            @click="selectTeamHospital(index)"
          >选择</el-button>
        </div>
      </div>
    </template>
    <div v-else class="search_none">
      <img src="~@/assets/images/search-none.png" alt>
      <p class="txt">暂无记录~</p>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    teamHospitalList: {
      type: Array,
      default: []
    },
    consType: {
      type: String,
      default: 'hospital'
    }
  },
  data() {
    return {

    }
  },
  methods: {
    // 查看详情
    goDetails(index) {
      if (this.consType == 'hospital') {
        this.$emit('hospitalDetails', { index: index })
      } else {
        this.$emit('teamDetails', { index: index })
      }
    },
    // 选择团队
    selectTeamHospital(index) {
      let _obj = null
      if (this.consType == 'hospital') {
        _obj = { hospital: this.teamHospitalList[index] }
      } else {
        _obj = { team: this.teamHospitalList[index] }
      }
      this.$emit('selectTeamHospital', _obj)
    }
  }

}
</script>

<style lang="scss" scoped>
.cons_doctor_grid {
  display: flex;
  flex-wrap: wrap;
  .cons_doctor_item {
    width: 188px;
    border: solid 1px #ccc;
    border-radius: 6px;
    text-align: center;
    padding: 5px 5px 20px;
    margin: 10px;
    .cons_doctor_info {
      .info {
        font-size: 14px;
        color: #333;
        text-align: left;
        line-height: 1.5em;
        margin: 10px 0 10px;
        padding: 0 10px;
        height: 42px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
      .avatar {
        margin: 0 auto;
        width: 100%;
        height: 120px;
        border: solid 1px #eee;
        border-radius: 4px;
        overflow: hidden;
        img {
          display: block;
          width: 100%;
          height: 100%;
        }
        // .itemImg {
        //   display: block;
        //   object-fit: contain;
        // }
        // .defaultImg {
        //   object-fit: contain;
        // }
      }
    }
    &:hover {
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    }
  }
}
.search_none {
  width: 100%;
  text-align: center;
  padding: 140px 0;
  .txt {
    padding: 10px 0;
    font-size: 16px;
    color: #ccc;
  }
}
</style>
